package graphs

import (
	"power/core/dao/table"
	"power/core/dao/graphdao"
	"power/core/localwrap"
)

var logGraphElementProtoFields = localwrap.GetLogger().Fork("power/core/service/graphs", "GraphElementProtoFields")

type GraphElementProtoFields struct{}

func (s GraphElementProtoFields) Query(param graphdao.GraphElementProtoFieldsQueryParam) ([]table.GraphElementProtoField, int64) {
	logGraphElementProtoFields.Debug().Func("Query").Interface("param", param).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	return graphdao.GraphElementProtoFields{RedisedMysql: d}.Query(param)
}

func (s GraphElementProtoFields) Get(id int) table.GraphElementProtoField {
	logGraphElementProtoFields.Debug().Func("Get").Int("id", id).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	return graphdao.GraphElementProtoFields{RedisedMysql: d}.Get(id)
}

func (s GraphElementProtoFields) Add(param graphdao.GraphElementProtoFieldsAddParam) table.GraphElementProtoField {
	logGraphElementProtoFields.Debug().Func("Add").Interface("param", param).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	return graphdao.GraphElementProtoFields{RedisedMysql: d}.Add(param)
}

func (s GraphElementProtoFields) Update(param graphdao.GraphElementProtoFieldsUpdateParam) {
	logGraphElementProtoFields.Debug().Func("Update").Interface("param", param).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	graphdao.GraphElementProtoFields{RedisedMysql: d}.Update(param)
}

func (s GraphElementProtoFields) Delete(id int) {
	logGraphElementProtoFields.Debug().Func("Delete").Int("id", id).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	graphdao.GraphElementProtoFields{RedisedMysql: d}.Delete(id)
}

//ListByProtoId
func (s GraphElementProtoFields) ListByProtoId(protoId int) []table.GraphElementProtoField {
	logGraphElementProtoFields.Debug().Func("ListByProtoId").Int("protoId", protoId).Send()
	d := localwrap.GetRedisedMysql()
	defer d.Close()
	return graphdao.GraphElementProtoFields{RedisedMysql: d}.ListByProtoId(protoId)
}
